home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 2080 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: doc.ic.ac.uk!not-for-mail
  2. From: mdf@doc.ic.ac.uk (Martin Frost)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: More linked list nonsense
  5. Date: 26 Jan 1996 15:29:59 -0000
  6. Organization: Dept. of Computing, Imperial College, University of London, UK.
  7. Distribution: world
  8. Message-ID: <4eas1n$46h@oak22.doc.ic.ac.uk>
  9. References: <4e5nih$iib@news.sdd.hp.com>
  10. Reply-To: mdf@doc.ic.ac.uk (Martin Frost)
  11. NNTP-Posting-Host: oak22.doc.ic.ac.uk
  12. X-Newsreader: mxrn 6.18-23
  13.  
  14.  
  15. In article <4e5nih$iib@news.sdd.hp.com>, Jeff Grimmett <jgrimm@sdd.hp.com> writes:
  16. >It just occurred to me last night, as I pored over steaming code, that 
  17. >the function Remove() (used to remove nodes from linked lists) might 
  18. >POSSIBLY not be freeing the memory allocated to the node it is removing. 
  19. >Does anyone have some insight on this?  It's difficult to deallocate a 
  20. >node once it's not part of the list, but it's pretty STUPID to free it 
  21. >BEFORE. :-)
  22.  
  23. Remove() is a low-level list manipulation function. To see what it does, look
  24. at the macro REMOVE in the assembly file "exec/lists.i".
  25.  
  26. It frees no memory, does no list arbitration, and makes no assumptions about
  27. anything other than that the first 8 bytes of the specified node are a
  28. MinimalListNode structure (ie pointer to next, pointer to previous). Since
  29. standard ListNodes simply have additional data tacked on the end, this works
  30. for all such nodes. You are responsible for freeing any memory associated with
  31. the node (or indeed you may not want to, for example if the node is embedded
  32. as preinitialised data in your program's code).
  33.  
  34. I don't know if the exec.library function returns a pointer to the node or
  35. not: I don't have the Autodocs with me right now. Even if it doesn't, it isn't
  36. really *too* much effort to cache the node pointer in a variable while calling
  37. the function :-)
  38.  
  39. Martin
  40.